﻿<BadHabit_Factory_Controls:GenericPanel
    x:Class="BadHabit.Factory.Controls.SummaryPanel"
    x:Name="summaryPanel"
    
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:BadHabit_Factory_Controls="clr-namespace:BadHabit.Factory.Controls"             
    xmlns:BadHabit_Factory="clr-namespace:BadHabit.Factory"             
    xmlns:BadHabit_WPFTools="clr-namespace:BadHabit.WPFTools;assembly=BadHabit.WPFTools" 
    xmlns:Microsoft_Toolkit="http://schemas.microsoft.com/wpf/2008/toolkit"
        
    xmlns:core="clr-namespace:System;assembly=mscorlib" 
    
    xmlns:props="clr-namespace:BadHabit.Factory.Windows.Properties"
    
    Loaded="summaryPanel_Loaded"
    
    DataContextChanged="summaryPanel_DataContextChanged"
    
    VerticalAlignment="Stretch"
    Background="Transparent">
    
    <BadHabit_Factory_Controls:GenericPanel.Resources>
        
        <DataTemplate x:Key="ParentProjectItemTemplate">
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding ClientName, StringFormat='{}{0} - '}"/>
                <TextBlock Text="{Binding ProjectName}"/>
                <TextBlock Text="{Binding ProjectNumber, StringFormat='{} [{0}]'}"/>
            </StackPanel>                        
        </DataTemplate>
        
                        
    </BadHabit_Factory_Controls:GenericPanel.Resources>
        
        

   

    <!-- PANEL COMMANDS -->
    <BadHabit_Factory_Controls:GenericPanel.CommandBindings>        
        <CommandBinding Command="BadHabit_Factory:FactoryCommands.StartProject" CanExecute="StartProject_CanExecute" Executed="StartProject_Executed"/>
        <CommandBinding Command="BadHabit_Factory:FactoryCommands.CancelProject" CanExecute="CancelProject_CanExecute" Executed="CancelProject_Executed"/>
        <CommandBinding Command="BadHabit_Factory:FactoryCommands.SuspendProject" CanExecute="SuspendProject_CanExecute"/>
        <CommandBinding Command="BadHabit_Factory:FactoryCommands.CloseProject" CanExecute="CloseProject_CanExecute" Executed="CloseProject_Executed"/>        
        <CommandBinding Command="ApplicationCommands.Save" CanExecute="Save_CanExecute" Executed="Save_Executed"/>
    </BadHabit_Factory_Controls:GenericPanel.CommandBindings>



    <Grid x:Name="ContentPanel" DataContext="{Binding Project.DefaultView}" >
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <DockPanel Grid.Row="0">
            <ToolBar DockPanel.Dock="Left" ToolBarTray.IsLocked="True" Height="60"  >

                <Menu>
                    <MenuItem         
                    Style="{StaticResource ToolBarMenuItem}"                
                BadHabit_WPFTools:RoleChecker.RequiredVisibleRole="SCRUM_MASTER"                
                Header="{x:Static props:Resources.Start_Project}"
                        CommandTarget="{Binding ElementName=scrollViewerPanel}"
                Command="BadHabit_Factory:FactoryCommands.StartProject" >
                        <MenuItem.Icon>
                            <Image Source="/Images/ToolBar/StartProject.png" Stretch="Uniform" Width="32" Height="32"/>
                        </MenuItem.Icon>
                    </MenuItem>

                    <MenuItem                                    
                BadHabit_WPFTools:RoleChecker.RequiredVisibleRole="SCRUM_MASTER"                
                        CommandTarget="{Binding ElementName=scrollViewerPanel}"
                Command="BadHabit_Factory:FactoryCommands.SuspendProject"
                    IsCheckable="True"
                IsChecked="{Binding IsSuspended}" >
                        <MenuItem.Icon>
                            <Image Source="/Images/ToolBar/SuspendProject.png" Stretch="Uniform" Width="32" Height="32"/>
                        </MenuItem.Icon>
                        <MenuItem.Style>
                            <Style TargetType="MenuItem" BasedOn="{StaticResource ToolBarMenuItem}">
                                <Style.Triggers>
                                    <Trigger Property="IsChecked" Value="True">
                                        <Setter Property="Header" Value="{x:Static props:Resources.Resume}"/>
                                    </Trigger>
                                    <Trigger Property="IsChecked" Value="False">
                                        <Setter Property="Header" Value="{x:Static props:Resources.Suspend}"/>
                                    </Trigger>
                                </Style.Triggers>
                            </Style>
                        </MenuItem.Style>

                    </MenuItem>


                    <MenuItem
                    Style="{StaticResource ToolBarMenuItem}"                                
                BadHabit_WPFTools:RoleChecker.RequiredVisibleRole="SCRUM_MASTER"
                Header="{x:Static props:Resources.Close_Project}"
                        CommandTarget="{Binding ElementName=scrollViewerPanel}"
                Command="BadHabit_Factory:FactoryCommands.CloseProject" >
                        <MenuItem.Icon>
                            <Image Source="/Images/ToolBar/CloseProject.png" Stretch="Uniform" Width="32" Height="32"/>
                        </MenuItem.Icon>
                    </MenuItem>

                    <MenuItem
                    Style="{StaticResource ToolBarMenuItem}"
                
                BadHabit_WPFTools:RoleChecker.RequiredVisibleRole="SCRUM_MASTER"
                
                Header="{x:Static props:Resources.Cancel_Project}"
                        CommandTarget="{Binding ElementName=scrollViewerPanel}"
                Command="BadHabit_Factory:FactoryCommands.CancelProject" >
                        <MenuItem.Icon>
                            <Image Source="/Images/ToolBar/CancelProject.png" Stretch="Uniform" Width="32" Height="32"/>
                        </MenuItem.Icon>
                    </MenuItem>



                </Menu>
            </ToolBar>
            <Button
                        x:Name="commitButton"
                        DockPanel.Dock="Right"
                        Style="{StaticResource CommitButton}"
                        Command="ApplicationCommands.Save"
                        HorizontalAlignment="Right" 
                        Margin="5" />
        </DockPanel>
        

        <ScrollViewer
                x:Name="scrollViewerPanel"
                Grid.Row="1"
                ScrollViewer.VerticalScrollBarVisibility="Auto">

           

                <Grid Margin="3" >
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>

                    <StackPanel  Grid.Column="0">
                        <!-- SUMMARY GROUP -->
                        <GroupBox Header="{x:Static props:Resources.Summary}">

                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition Width="400"/>
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="Auto"/>
                                  
                                </Grid.RowDefinitions>

                            <Grid Grid.Row="0" Grid.Column="1" Margin="6,0,0,0">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition />
                                    <ColumnDefinition />
                                </Grid.ColumnDefinitions>
                                <BadHabit_Factory_Controls:ProjectSizeIndicator                                
                                x:Name="sizeIndicator"
                                Grid.Column="0"
                                HorizontalAlignment="Left"
                                Margin="0"
                                IndicatorName="{x:Static props:Resources.Backlog_Size}"
                                ToolTip="{x:Static props:Resources.Backlog_Size_tooltip}"
                                >
                                    <BadHabit_Factory_Controls:ProjectSizeIndicator.IndicadorIcon>
                                        <BitmapImage UriSource="/Images/BacklogItemStatus/itemDone.png"/>
                                    </BadHabit_Factory_Controls:ProjectSizeIndicator.IndicadorIcon>
                                    <BadHabit_Factory_Controls:ProjectSizeIndicator.IndicadorOffIcon>
                                        <BitmapImage UriSource="/Images/BacklogItemStatus/itemOff.png"/>
                                    </BadHabit_Factory_Controls:ProjectSizeIndicator.IndicadorOffIcon>
                                </BadHabit_Factory_Controls:ProjectSizeIndicator>
                                <BadHabit_Factory_Controls:ProjectSizeIndicator                                
                                x:Name="incomeIndicator"
                                Margin="0"
                                Grid.Column="1"
                                HorizontalAlignment="Right"
                                IndicatorName="{x:Static props:Resources.Budget_Size}"
                                ToolTip="{x:Static props:Resources.Budget_Size_tooltip}"
                                
                                >
                                    <BadHabit_Factory_Controls:ProjectSizeIndicator.IndicadorIcon>
                                        <BitmapImage UriSource="/Images/Icons/money.png"/>
                                    </BadHabit_Factory_Controls:ProjectSizeIndicator.IndicadorIcon>
                                    <BadHabit_Factory_Controls:ProjectSizeIndicator.IndicadorOffIcon>
                                        <BitmapImage UriSource="/Images/Icons/moneyOff.png"/>
                                    </BadHabit_Factory_Controls:ProjectSizeIndicator.IndicadorOffIcon>
                                </BadHabit_Factory_Controls:ProjectSizeIndicator>
                            </Grid>



                            <TextBlock Grid.Row="1" Grid.Column="0" Style="{StaticResource Label}" Text="{x:Static props:Resources.Project_number}" />
                                <TextBox                                                            
                                    Grid.Row="1" Grid.Column="1" Style="{StaticResource LabelInfo}" Text="{Binding ProjectNumber}"/>

              

                            <TextBlock Grid.Row="2" Grid.Column="0" Style="{StaticResource Label}" Text="{x:Static props:Resources.Project_name}" />
                                <TextBox 
                        x:Name="projectNameTextBox"
                        BadHabit_WPFTools:RoleChecker.RequiredEditRole="SCRUM_MASTER"
                        Grid.Row="2" Grid.Column="1" Style="{StaticResource FormTextBox}" HorizontalAlignment="Stretch" Text="{Binding ProjectName}"/>

                                <TextBlock Grid.Row="3" Grid.Column="0" Style="{StaticResource Label}" Text="{x:Static props:Resources.Client}" />
                                <BadHabit_WPFTools:ComboBox
                        BadHabit_WPFTools:RoleChecker.RequiredEditRole="SCRUM_MASTER"
                        x:Name="clientComboBox" Grid.Row="3" Grid.Column="1"                      
                          ItemsSource="{Binding Source={StaticResource ClientList}}"
                          SelectedValue="{Binding ClientName}"
                          SelectionChanged="clientComboBox_SelectionChanged"
                          IsEditable="True"
                          Style="{StaticResource FormComboBox}"
                      />



                                <TextBlock Grid.Row="4" Grid.Column="0" Style="{StaticResource Label}" VerticalAlignment="Top" Text="{x:Static props:Resources.Description}" />
                                <TextBox
                        BadHabit_WPFTools:RoleChecker.RequiredEditRole="SCRUM_MASTER"
                        Grid.Row="4" Grid.Column="1"                        
                        Style="{StaticResource FormTextBox}"
                        HorizontalAlignment="Stretch" AcceptsReturn="True" TextWrapping="Wrap" MaxHeight="100" ScrollViewer.VerticalScrollBarVisibility="Auto"
                        Text="{Binding Description}"/>

           


                            <TextBlock Grid.Row="5" Grid.Column="0" Style="{StaticResource Label}" Text="{x:Static props:Resources.Project_life_cycle}" />
                                <TextBox                        
                        Grid.Row="5" Grid.Column="1" Style="{StaticResource LabelInfo}" Text="{Binding Category}" />

                                <TextBlock Grid.Row="6" Grid.Column="0" Style="{StaticResource Label}" Text="{x:Static props:Resources.Project_plataform}" />
                                <BadHabit_WPFTools:ComboBox
                        BadHabit_WPFTools:RoleChecker.RequiredEditRole="SCRUM_MASTER"
                Grid.Row="6" Grid.Column="1"
                                    
                ItemsSource="{Binding Source={StaticResource ProjectPlataformList}}"
                DisplayMemberPath="Plataform"
                SelectedValuePath="Plataform"
                SelectedValue="{Binding Plataform}"
                Style="{StaticResource FormComboBox}" />

                            <TextBlock Grid.Row="7" Grid.Column="0" Style="{StaticResource Label}" Text="{x:Static props:Resources.Project_type}" />
                            <BadHabit_WPFTools:ComboBox
                        BadHabit_WPFTools:RoleChecker.RequiredEditRole="SCRUM_MASTER"
                        Grid.Row="7"
                        Grid.Column="1"
                        ItemsSource="{Binding Source={StaticResource ProjectModelList}}"
                        DisplayMemberPath="Model"
                        SelectedValuePath="Model"
                        SelectedValue="{Binding Model}"
                        Style="{StaticResource FormComboBox}" />

                            <TextBlock Grid.Row="8" Grid.Column="0" Style="{StaticResource Label}" Text="{x:Static props:Resources.Project_network_folder}" />
                            <TextBox 
                        BadHabit_WPFTools:RoleChecker.RequiredEditRole="SCRUM_MASTER"
                        Grid.Row="8" Grid.Column="1" Style="{StaticResource FormTextBox}" Text="{Binding ProjectDocBase}" />

                            <TextBlock Grid.Row="9" Grid.Column="0" Style="{StaticResource Label}" Text="{x:Static props:Resources.Created_by}"/>
                            <TextBox Grid.Row="9" Grid.Column="1" Style="{StaticResource LabelInfo}" Text="{Binding ProjectOwner}" />

                            <TextBlock Grid.Row="10" Grid.Column="0" Style="{StaticResource Label}" Text="{x:Static props:Resources.Created_at}"/>
                            <TextBox Grid.Row="10" Grid.Column="1" Style="{StaticResource LabelInfo}" Text="{Binding CreateDate}" />

                         

                            </Grid>
                        </GroupBox>

                        <!-- DEADLINE GROUP -->
                        <GroupBox Header="{x:Static props:Resources.Timeline}">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition Width="10"/>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition Width="Auto"/>

                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="Auto"/>

                                </Grid.RowDefinitions>

                            <TextBlock Grid.Row="0" Grid.Column="0" Style="{StaticResource Label}" Text="{x:Static props:Resources.Should_start_at}"/>

                            <Microsoft_Toolkit:DatePicker                                        
                                    BadHabit_WPFTools:RoleChecker.RequiredEnableRole="SCRUM_MASTER"
                                    Grid.Row="0" Grid.Column="1"                                                                           
                                    SelectedDate="{Binding EstimatedStartDate, ValidatesOnExceptions=True}"/>

                            <TextBlock Grid.Row="0" Grid.Column="3" Style="{StaticResource Label}" Text="{x:Static props:Resources.Should_be_done_by}"/>
                            <TextBox x:Name="shouldBeDoneByTextBlock" Grid.Row="0" Grid.Column="4" Style="{StaticResource LabelInfo}"
                               Text="{Binding EstimatedEndDate, StringFormat='{}{0:d}'}"   />

                            <TextBlock Grid.Row="1" Grid.Column="0" Style="{StaticResource Label}" Text="{x:Static props:Resources.Started_at}"/>
                            <TextBox Grid.Row="1" Grid.Column="1"  Text="{Binding StartDate, StringFormat='{}{0:d}'}"  Style="{StaticResource LabelInfo}"/>

                            <TextBlock Grid.Row="1" Grid.Column="3" Style="{StaticResource Label}" Text="{x:Static props:Resources.Finished_at}"/>
                            <TextBox Grid.Row="1" Grid.Column="4" Text="{Binding EndDate, StringFormat='{}{0:d}'}"  Style="{StaticResource LabelInfo}"/>


                            </Grid>
                        </GroupBox>
                    </StackPanel>
                    <StackPanel Grid.Column="1">

                        <GroupBox Header="{x:Static props:Resources.Indicators}" Margin="10,0,5,3">
                        <Border Background="#FAFAFA" BorderBrush="#DDDDDD" BorderThickness="1" Padding="3">
                            <StackPanel>

                                <BadHabit_Factory_Controls:ProjectIndicator
                                x:Name="walkedIndicator"
                                IndicatorName="{x:Static props:Resources.WWalked}"
                                IndicatorUnit="%"                                                                
                                IndicatorToolTip="{x:Static props:Resources.Walked_Indicator_tooltip}"
                                Margin="4" >
                                    <BadHabit_Factory_Controls:ProjectIndicator.IndicadorIcon>
                                        <BitmapImage UriSource="/Images/Toolbar/projectBurndown.png"/>
                                    </BadHabit_Factory_Controls:ProjectIndicator.IndicadorIcon>
                                </BadHabit_Factory_Controls:ProjectIndicator>

                                <BadHabit_Factory_Controls:ProjectIndicator
                                x:Name="budgetIndicator"
                                IndicatorName="{x:Static props:Resources.Budget}"
                                IndicatorUnit="%"                                                                
                                IndicatorToolTip="{x:Static props:Resources.Budget_Indicator_tooltip}"
                                Margin="4" >
                                    <BadHabit_Factory_Controls:ProjectIndicator.IndicadorIcon>
                                        <BitmapImage UriSource="/Images/Icons/money.png"/>
                                    </BadHabit_Factory_Controls:ProjectIndicator.IndicadorIcon>
                                </BadHabit_Factory_Controls:ProjectIndicator>


                                <BadHabit_Factory_Controls:ProjectIndicator                                
                                x:Name="deadlineIndicator"
                                IndicatorName="{x:Static props:Resources.Deadline}"
                                IndicatorUnit="{x:Static props:Resources.hrs}"                                                                          
                                IndicatorToolTip="{x:Static props:Resources.Deadline_Indicator_tooltip}"
                                Margin="4" >
                                    <BadHabit_Factory_Controls:ProjectIndicator.IndicadorIcon>
                                        <BitmapImage UriSource="/Images/Icons/clock.png"/>
                                    </BadHabit_Factory_Controls:ProjectIndicator.IndicadorIcon>
                                </BadHabit_Factory_Controls:ProjectIndicator>


                                <BadHabit_Factory_Controls:ProjectIndicator
                                x:Name="qualityIndicator"
                                IndicatorName="{x:Static props:Resources.Quality}"
                                IndicatorUnit="%"                                                                
                                IndicatorToolTip="{x:Static props:Resources.Quality_Indicator_tooltip}"
                                Margin="4" >
                                    <BadHabit_Factory_Controls:ProjectIndicator.IndicadorIcon>
                                        <BitmapImage UriSource="/Images/TaskType/32x32/DEVELOPING_BUG.png"/>
                                    </BadHabit_Factory_Controls:ProjectIndicator.IndicadorIcon>
                                </BadHabit_Factory_Controls:ProjectIndicator>

                                <BadHabit_Factory_Controls:ProjectIndicator
                                x:Name="velocityIndicator"
                                IndicatorName="{x:Static props:Resources.Team_Velocity}"
                                IndicatorUnit="{x:Static props:Resources.pts_hrs}"                                                                
                                IndicatorToolTip="{x:Static props:Resources.Team_Velocity_Indicator_tooltip}"
                                Margin="4" >
                                    <BadHabit_Factory_Controls:ProjectIndicator.IndicadorIcon>
                                        <BitmapImage UriSource="/Images/Icons/velocity.png"/>
                                    </BadHabit_Factory_Controls:ProjectIndicator.IndicadorIcon>
                                </BadHabit_Factory_Controls:ProjectIndicator>


                            </StackPanel>

                        </Border>

         



                        </GroupBox>

                    <StackPanel
                        Grid.Row="11" Grid.Column="1"
                        Orientation="Horizontal">



                        <TextBlock VerticalAlignment="Center" Margin="10,0,10,0">
                            <Hyperlink Click="Hyperlink_Click">
                                <TextBlock Text="{x:Static props:Resources.Go_to_parent_project}"/>
                            </Hyperlink>
                            <TextBlock.Style>
                            <Style TargetType="TextBlock">
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding PaymentProjectUId}" Value="{x:Null}">
                                        <Setter Property="Visibility" Value="Collapsed"/>
                                    </DataTrigger>                                
                                </Style.Triggers>                                    
                            </Style>
                            </TextBlock.Style>

                         </TextBlock>
                        
                        <TextBlock Name="changeParentButton"  Margin="10,0,10,0">
                            <Hyperlink  Click="changeParent_Click">
                                <TextBlock Text="{x:Static props:Resources.Change_parent_project}"/>
                            </Hyperlink>
                        </TextBlock>

                        <BadHabit_WPFTools:ComboBox
                            x:Name="parentProjectUIdComboBox"
                            Margin="10,0,10,0"
                            Visibility="Collapsed"
                            SelectedValue="{Binding PaymentProjectUId}"                            
                            SelectedValuePath="ProjectUId"
                            ItemTemplate="{StaticResource ParentProjectItemTemplate}"
                            DropDownClosed="parentProjectUIdComboBox_DropDownClosed"
                            Style="{StaticResource FormComboBox}"/>


                    </StackPanel>

                </StackPanel>


                </Grid>

            
        </ScrollViewer>


        
        


        
    </Grid>

</BadHabit_Factory_Controls:GenericPanel>
